home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 5 / Apprentice-Release5.iso / Environments / SmallEiffel 0.3.3 / SmallEiffel PPC / diff / lib_std.old < prev    next >
Encoding:
Text File  |  1996-06-13  |  27.1 KB  |  1,112 lines  |  [TEXT/EDIT]

  1. Only in /users/prof/colnet/SmallEiffel/lib_std: arguments.e
  2. diff -r lib_std/array.e /users/prof/colnet/SmallEiffel/lib_std/array.e
  3. 37,38c37,38
  4. <      if storage /= Void then
  5. <         c_inline_c("free(C->_storage);");
  6. ---
  7. >      if storage.is_not_void then
  8. >         free_pointer(storage);
  9. 43d42
  10. <      storage := Void;
  11. 46,47c45
  12. <         c_inline_c("C->_storage=malloc%
  13. <                %((size_t)((C->_capacity)*sizeof(*(C->_storage))));");
  14. ---
  15. >         storage := malloc(capacity);
  16. 80,81c78,79
  17. <      if storage /= Void then
  18. <         c_inline_c("free(C->_storage);");
  19. ---
  20. >      if storage.is_not_void then
  21. >         free_pointer(storage);
  22. 83c81,82
  23. <      c_inline_c("memcpy(C,_other,sizeof(*C));free(_other);");
  24. ---
  25. >      standard_copy(other);
  26. >      other.free_array;
  27. 88c87
  28. <    infix "@", item (index: INTEGER): E is
  29. ---
  30. >    item, infix "@" (index: INTEGER): E is
  31. 90,94c89,91
  32. <      check
  33. <         storage /= Void;
  34. <         capacity >= (upper - lower + 1);
  35. <      end;
  36. <      c_inline_c("R=(C->_storage)[a1-(C->_lower)];")
  37. ---
  38. >      if storage = Void then end;
  39. >      if lower = Void then end;
  40. >      c_inline_c("R=(((C->_storage))[a1-(C->_lower)]);")
  41. 102c99,101
  42. <      c_inline_c("(C->_storage)[a2-(C->_lower)]=a1;");
  43. ---
  44. >      if storage = Void then end;
  45. >      if lower = Void then end;
  46. >      c_inline_c("((C->_storage)[a2-(C->_lower)])=a1;");
  47. 205a205
  48. >      if storage = Void then end;
  49. 207,209c207,209
  50. <         capacity := capacity + 16;
  51. <         if capacity = 16 then
  52. <            c_inline_c("C->_storage=malloc(16*sizeof(*(C->_storage)));");
  53. ---
  54. >         if capacity = 0 then
  55. >            capacity := 16;
  56. >            storage := malloc(capacity);
  57. 211,212c211,212
  58. <            c_inline_c("C->_storage=realloc(C->_storage,%
  59. <               %((C->_capacity)*sizeof(*(C->_storage))));");
  60. ---
  61. >            capacity := capacity + 16;
  62. >            storage := realloc(storage,capacity);
  63. 322c322,353
  64. <       
  65. ---
  66. > feature {NONE}
  67. >    malloc(size: INTEGER): POINTER is
  68. >       require
  69. >      size > 0
  70. >       do
  71. >      c_inline_c("R=malloc((size_t)(a1*sizeof(*(C->_storage))));");
  72. >       end;
  73. >    realloc(pointer: POINTER; size: INTEGER): POINTER is
  74. >       require
  75. >      size > 0
  76. >       do           
  77. >      c_inline_c("R=realloc(a1,%
  78. >              %((size_t)(a2*sizeof(*(C->_storage)))));");
  79. >       end;
  80. >    free_pointer(p: POINTER) is
  81. >       require
  82. >      p.is_not_void
  83. >       external "C"
  84. >       alias "free"
  85. >       end;
  86. > feature {ARRAY}
  87. >    free_array is
  88. >       external "CWC"
  89. >       alias "free"
  90. >       end;
  91. 326c357,359
  92. <       
  93. ---
  94. >    capacity > 0 implies storage.is_not_void;
  95. diff -r lib_std/array.e /users/prof/colnet/SmallEiffel/lib_std/array.elib_std/boolean.e /users/prof/colnet/SmallEiffel/lib_std/boolean.e
  96. 20c20,21
  97. <       external "CSE"
  98. ---
  99. >       do
  100. >      Result := Current and then other;
  101. 35c36,37
  102. <       external "CSE"
  103. ---
  104. >       do
  105. >      Result := Current or else other;
  106. 55c57,61
  107. <       external "CSE"
  108. ---
  109. >       do
  110. >      if Current then
  111. >      else
  112. >         Result := true;
  113. >      end;
  114. diff -r lib_std/boolean.e /users/prof/colnet/SmallEiffel/lib_std/boolean.elib_std/boolean_ref.e /users/prof/colnet/SmallEiffel/lib_std/boolean_ref.e
  115. 11,12c11
  116. < creation {ANY}
  117. <     make
  118. ---
  119. > creation make
  120. 14c13
  121. < feature {ANY}
  122. ---
  123. > feature 
  124. 22a22,28
  125. >       end;
  126. > feature
  127. >    
  128. >    set_item(value: like item) is
  129. >       do
  130. >      item := value;
  131. diff -r lib_std/boolean_ref.e /users/prof/colnet/SmallEiffel/lib_std/boolean_ref.elib_std/character.e /users/prof/colnet/SmallEiffel/lib_std/character.e
  132. 22c22
  133. <    infix "<"(other: CHARACTER): BOOLEAN is
  134. ---
  135. >    infix "<" (other: CHARACTER): BOOLEAN is
  136. 24c24,25
  137. <       external "CSE"
  138. ---
  139. >       do
  140. >      Result := code < other.code;
  141. 29c30,31
  142. <       external "CSE"
  143. ---
  144. >       do
  145. >      Result := code <= other.code;
  146. 34c36,37
  147. <       external "CSE"
  148. ---
  149. >       do
  150. >      Result := code > other.code;
  151. 39c42,43
  152. <       external "CSE"
  153. ---
  154. >       do
  155. >      Result := code >= other.code;
  156. 62c66
  157. <    same_as(other : CHARACTER): BOOLEAN is
  158. ---
  159. >    same_as(other: CHARACTER): BOOLEAN is
  160. 65c69,80
  161. <      Result := to_lower = other.to_lower;
  162. ---
  163. >      if Current = other then
  164. >         Result := true;
  165. >      else
  166. >         inspect
  167. >            code
  168. >         when 65 .. 90 then
  169. >            Result := Current = other.to_upper;
  170. >         when 97 .. 122 then
  171. >            Result := Current = other.to_lower;
  172. >         else
  173. >         end;
  174. >      end;
  175. diff -r lib_std/character.e /users/prof/colnet/SmallEiffel/lib_std/character.elib_std/character_ref.e /users/prof/colnet/SmallEiffel/lib_std/character_ref.e
  176. 8,9c8
  177. < creation {ANY}
  178. <    make
  179. ---
  180. > creation make
  181. 11c10
  182. < feature {ANY}
  183. ---
  184. > feature 
  185. 19a19,25
  186. > feature
  187. >    
  188. >    set_item(value: like item) is
  189. >       do
  190. >      item := value;
  191. >       end;
  192. diff -r lib_std/character_ref.e /users/prof/colnet/SmallEiffel/lib_std/character_ref.elib_std/double_ref.e /users/prof/colnet/SmallEiffel/lib_std/double_ref.e
  193. 17,18c17
  194. < creation {ANY}
  195. <    make
  196. ---
  197. > creation make
  198. 20c19
  199. < feature {ANY}
  200. ---
  201. > feature 
  202. 28a28,34
  203. > feature
  204. >    
  205. >    set_item(value: like item) is
  206. >       do
  207. >      item := value;
  208. >       end;
  209. diff -r lib_std/double_ref.e /users/prof/colnet/SmallEiffel/lib_std/double_ref.elib_std/fixed_array.e /users/prof/colnet/SmallEiffel/lib_std/fixed_array.e
  210. 20c20
  211. <    make, resize
  212. ---
  213. >    make, resize, from_collection
  214. 41a42,43
  215. >       local
  216. >      model: like item;
  217. 43,44c45,48
  218. <      if storage /= Void then
  219. <         c_inline_c("free(C->_storage);");
  220. ---
  221. >      if storage.is_not_void then
  222. >         storage := realloc(storage,size,model);
  223. >      else
  224. >         storage := malloc(size,model);
  225. 46,47d49
  226. <      c_inline_c("C->_storage=malloc(((size_t)%
  227. <             %sizeof(*(C->_storage))*a1));");
  228. 53a56,74
  229. >    from_collection(cltn: COLLECTION[E]) is
  230. >       local
  231. >      fa_index, cltn_index: INTEGER;
  232. >       do
  233. >      from
  234. >         make(cltn.count);
  235. >         fa_index := upper;
  236. >         cltn_index := cltn.upper;
  237. >      until
  238. >         fa_index < 0
  239. >      loop
  240. >         put(cltn.item(cltn_index),fa_index);
  241. >         cltn_index := cltn_index - 1;
  242. >         fa_index := fa_index - 1;
  243. >      end;
  244. >       ensure
  245. >      count = cltn.count
  246. >       end;
  247. 59c80,81
  248. <      c_inline_c("R=(C->_storage)[a1];")
  249. ---
  250. >      if storage = Void then end;
  251. >      c_inline_c("R=((C->_storage)[a1]);")
  252. 66c88
  253. <      c_inline_c("(C->_storage)[a2]=a1;");
  254. ---
  255. >      c_inline_c("((C->_storage)[a2])=a1;");
  256. 73,76d94
  257. <      if storage /= Void then
  258. <         c_inline_c("free(C->_storage);");
  259. <         storage := Void;
  260. <      end;
  261. 157c175,191
  262. <       
  263. ---
  264. > feature {NONE}
  265. >    malloc(size: INTEGER; model: like item): POINTER is
  266. >       require
  267. >      size > 0
  268. >       do
  269. >      c_inline_c("R=malloc((size_t)(a1*sizeof(a2)));");
  270. >       end;
  271. >    realloc(pointer: POINTER; size: INTEGER; model: like item): POINTER is
  272. >       require
  273. >      size > 0
  274. >       do
  275. >      c_inline_c("R=realloc(a1,(size_t)(a2*sizeof(a3)));");
  276. >       end;
  277. diff -r lib_std/fixed_array.e /users/prof/colnet/SmallEiffel/lib_std/fixed_array.elib_std/general.e /users/prof/colnet/SmallEiffel/lib_std/general.e
  278. 123c123
  279. < -- ELKS problem for expanded target.
  280. ---
  281. > -- ELKS95 bug for expanded target.
  282. 158c158,159
  283. <      same_type: Result implies same_type(other);
  284. ---
  285. > -- ***     same_type: Result implies same_type(other);
  286. > -- ELKS95 bug for expanded target.
  287. 165,166c166,167
  288. <      -- Void if `other' is Void; otherwise new object 
  289. <      -- equal to `other'. 
  290. ---
  291. >      -- When argument `other' is Void, call `twin' otherwise 
  292. >      -- return Void. 
  293. 169c170,190
  294. <         c_inline_c("R=(T0 *)se_new(a1->id);");
  295. ---
  296. >         Result := other.twin;
  297. >      end;
  298. >       ensure
  299. >      equal: equal(Result,other);
  300. >       end;
  301. >    frozen twin: like Current is
  302. >      -- Return an initialized new object using target as model.
  303. >      -- Result as the same `generating_type' as the target of the 
  304. >      -- call. Before to be returned, the corresponding `copy' feature
  305. >      -- is called.
  306. >       do
  307. >      if is_expanded_type then
  308. >         if is_basic_expanded_type then
  309. >            Result := Current;
  310. >         else
  311. >            Result := Current;
  312. >            Result.copy(Current);
  313. >         end;
  314. >      else
  315. >         c_inline_c("R=(T0 *)se_new(C->id);");
  316. 171c192
  317. <         Result.copy(other);
  318. ---
  319. >         Result.copy(Current);
  320. 175c196
  321. <      equal: equal(Result,other);
  322. ---
  323. >      equal: Result.is_equal(Current);
  324. 345c366
  325. <       external "CSE"
  326. ---
  327. >       do
  328. 352a374,375
  329. >       local
  330. >      p: POINTER;
  331. 354c377
  332. <      path.extend('%U');
  333. ---
  334. >      p := path.to_external;
  335. 356c379
  336. <          "{FILE *f=fopen(((T7 *)a1)->_storage,%"r%");%N%
  337. ---
  338. >          "{FILE *f=fopen(((char*)_p),%"r%");%N%
  339. 359d381
  340. <      path.remove_last(1);
  341. 364a387,388
  342. >       local
  343. >      p: POINTER;
  344. 366,368c390,391
  345. <      path.extend('%U');
  346. <      c_inline_c("remove(((T7 *)a1)->_storage);");
  347. <      path.remove_last(1);
  348. ---
  349. >      p := path.to_external;
  350. >      c_inline_c("remove(((char*)_p));");
  351. 374a398,399
  352. >       local
  353. >      op, np: POINTER;
  354. 376,380c401,403
  355. <      old_path.extend('%U');
  356. <      new_path.extend('%U');
  357. <      c_inline_c("rename(((T7 *)a1)->_storage,((T7 *)a2)->_storage);");
  358. <      old_path.remove_last(1);
  359. <      new_path.remove_last(1);
  360. ---
  361. >      op := old_path.to_external;
  362. >      np := new_path.to_external;
  363. >      c_inline_c("rename(((char*)_op),((char*)_np));");
  364. 388c411,412
  365. <       external "CSE"
  366. ---
  367. >       do
  368. >      Result := command_arguments.upper;
  369. 399c423,424
  370. <       external "CSE"
  371. ---
  372. >       do
  373. >      Result := command_arguments.item(i);
  374. 402a428,450
  375. >    frozen command_arguments: ARRAY[STRING] is
  376. >      --                  ***** FIXED_ARRAY[STRING]
  377. >      -- Give an acces to arguments command line including the
  378. >      -- command name at index 0.
  379. >       local
  380. >      i: INTEGER;
  381. >      arg: STRING;
  382. >       once
  383. >      from
  384. >         c_inline_c("_i=se_argc-1;");
  385. >         !!Result.make(0,i);
  386. >      until
  387. >         i < 0
  388. >      loop
  389. >         c_inline_c("_arg=((T0*)e2s(se_argv[_i]));");
  390. >         Result.put(arg,i);
  391. >         i := i - 1;
  392. >      end;
  393. >       ensure
  394. >      Result.lower = 0; -- *****  FIXED_ARRAY 
  395. >      not Result.empty
  396. >       end;
  397. 409a458,459
  398. >       local
  399. >      p: POINTER;
  400. 411,414c461,465
  401. <      name.extend('%U');
  402. <      c_inline_c("R=((T0 *)getenv(((T7 *)a1)->_storage));%N%
  403. <             %if (R) R=((T0 *)e2s((char *)R));")
  404. <      name.remove_last(1);
  405. ---
  406. >      p := name.to_external;
  407. >      c_inline_c("_p=((void*)getenv((char*)_p));");
  408. >      if p.is_not_void then
  409. >         c_inline_c("R=(T0*)e2s((char*)_p);");
  410. >      end;
  411. 423a475,476
  412. >       local
  413. >      p: POINTER;
  414. 425,427c478,479
  415. <      cmd.extend('%U');
  416. <      c_inline_c("system(((T7 *)a1)->_storage);");
  417. <      cmd.remove_last(1);
  418. ---
  419. >      p := cmd.to_external;
  420. >      c_inline_c("system(((char*)_p));");
  421. 519c571
  422. <      -- Statically computed by SmallEiffel.
  423. ---
  424. >      -- Target is not evaluated (Statically computed).
  425. 521d572
  426. <      -- Target is not evaluated.
  427. 525a577,586
  428. >    frozen is_basic_expanded_type: BOOLEAN is
  429. >      -- Target is not evaluated (Statically computed).
  430. >      -- Result is true if target static type is one of the 
  431. >      -- following types : BOOLEAN, CHARACTER, INTEGER, REAL,
  432. >      -- DOUBLE or POINTER.
  433. >       external "CSE"
  434. >       ensure
  435. >      Result implies is_expanded_type
  436. >       end;
  437. >    
  438. 529,530c590
  439. <      -- The result is the C sizeof of the corresponding
  440. <      -- struct or basic object.
  441. ---
  442. >      -- The result is given in number of CHARACTER.
  443. 552a613,625
  444. >       end;
  445. > feature -- WARNING: For SmallEiffel Gurus's only. 
  446. >    -- Internal implementation of the SmallEiffel 
  447. >    -- debugger/interpretor (command `eval').
  448. >    eval_read_attribute(name: STRING; dest: POINTER) is do end;
  449. >    eval_write_attribute(name: STRING; source: POINTER) is do end;
  450. >    frozen eval_virtual_machine: EVAL_VIRTUAL_MACHINE is
  451. >       once
  452. >      !!Result.make;
  453. diff -r lib_std/general.e /users/prof/colnet/SmallEiffel/lib_std/general.elib_std/integer.e /users/prof/colnet/SmallEiffel/lib_std/integer.e
  454. 11,13c11,14
  455. <      infix "+", infix "-", infix "*", infix "/", infix "\\", infix "//", 
  456. <      infix "^", infix "<", infix "<=", infix ">", infix ">=", compare, 
  457. <      prefix "-", prefix "+", hash_code, one, zero, print_on
  458. ---
  459. >      infix "+", infix "-", infix "*", infix "/", infix "\\", 
  460. >      infix "//", infix "^", infix "<", infix "<=", infix ">",
  461. >      infix ">=", compare, prefix "-", prefix "+", hash_code, 
  462. >      one, zero, print_on
  463. 74c75
  464. <      -- Is Current smaller than `other'?
  465. ---
  466. >      -- Is 'Current' strictly less than 'other'?
  467. 79c80
  468. <      -- Is Current smaller or equal to `other'?
  469. ---
  470. >      -- Is 'Current' less or equal 'other'?
  471. 84c85
  472. <      -- Is Current greater than `other'?
  473. ---
  474. >      -- Is 'Current' strictly greater than 'other'?
  475. 89c90
  476. <      -- Is Current greater or equal to `other'?
  477. ---
  478. >      -- Is 'Current' greater or equal than 'other'?
  479. 134c135
  480. <      Result := to_real.sqrt;
  481. ---
  482. >      Result := to_double.sqrt;
  483. 176a178,184
  484. >    to_boolean: BOOLEAN is
  485. >       do
  486. >      if Current /= 0 then
  487. >         Result := true;
  488. >      end;
  489. >       end;
  490. 295c303,306
  491. <    tmp_string: STRING is "0000000000000000000";
  492. ---
  493. >    tmp_string: STRING is 
  494. >       once
  495. >      !!Result.make(128);
  496. >       end;
  497. diff -r lib_std/integer.e /users/prof/colnet/SmallEiffel/lib_std/integer.elib_std/integer_ref.e /users/prof/colnet/SmallEiffel/lib_std/integer_ref.e
  498. 17,18c17
  499. < creation {ANY}
  500. <    make
  501. ---
  502. > creation make
  503. 20c19
  504. < feature {ANY}
  505. ---
  506. > feature 
  507. 28a28,34
  508. > feature
  509. >    
  510. >    set_item(value: like item) is
  511. >       do
  512. >      item := value;
  513. >       end;
  514. diff -r lib_std/integer_ref.e /users/prof/colnet/SmallEiffel/lib_std/integer_ref.elib_std/platform.e /users/prof/colnet/SmallEiffel/lib_std/platform.e
  515. 8,9c8
  516. <    
  517. < feature {ANY}
  518. ---
  519. > feature -- Maximum :
  520. 11c10,16
  521. <     Maximum_character_code : INTEGER is 255
  522. ---
  523. >     Maximum_character_code : INTEGER is
  524. >      -- Largest supported code for CHARACTER values.
  525. >       once
  526. >      c_inline_c("R=CHAR_MAX;");
  527. >       ensure
  528. >      meaningful: Result >= 127
  529. >       end;
  530. 13c18,24
  531. < end -- class PLATFORM
  532. ---
  533. >     Maximum_integer: INTEGER is
  534. >       -- Largest supported value of type INTEGER.
  535. >       once
  536. >      c_inline_c("R=INT_MAX;");
  537. >       ensure
  538. >      meaningful: Result >= 0
  539. >       end;
  540. 14a26,127
  541. >     Maximum_real: REAL is
  542. >       -- Largest supported value of type REAL.
  543. >       once
  544. >      c_inline_c("R=FLT_MAX;");
  545. >       ensure
  546. >      meaningful: Result >= 0.0
  547. >       end;
  548. >     Maximum_double: DOUBLE is
  549. >       -- Largest supported value of type DOUBLE.
  550. >       once
  551. >      c_inline_c("R=DBL_MAX;");
  552. >       ensure
  553. >      meaningful: Result >= 0.0
  554. >       end;
  555. > feature -- Minimum :
  556. >    Minimum_character_code: INTEGER is
  557. >       -- Smallest supported code for CHARACTER values.
  558. >       once
  559. >      c_inline_c("R=CHAR_MIN;");
  560. >       ensure
  561. >      meaningful: Result <= 0
  562. >       end;
  563. >    Minimum_integer: INTEGER is
  564. >       -- Smallest supported value of type INTEGER.
  565. >       once
  566. >      c_inline_c("R=INT_MIN;");
  567. >       ensure
  568. >      meaningful: Result <= 0
  569. >       end;
  570. >    Minimum_double: DOUBLE is
  571. >       -- Smallest supported value of type DOUBLE.
  572. >       once
  573. >      Result := - Maximum_double;
  574. >       ensure
  575. >      meaningful: Result <= 0
  576. >       end;
  577. >    Minimum_real: REAL is
  578. >       -- Smallest supported value of type REAL.
  579. >       once
  580. >      Result := - Maximum_real;
  581. >       ensure
  582. >      meaningful: Result <= 0
  583. >       end;
  584. > feature -- Bits :
  585. >    Boolean_bits: INTEGER is
  586. >       -- Number of bits in a value of type BOOLEAN.
  587. >       once
  588. >      c_inline_c("R=(CHAR_BIT*sizeof(int));");
  589. >       ensure
  590. >      meaningful: Result >= 1
  591. >       end;
  592. >    Character_bits: INTEGER is
  593. >       -- Number of bits in a value of type CHARACTER.
  594. >       once
  595. >      c_inline_c("R=CHAR_BIT;");
  596. >       ensure
  597. >      meaningful: Result >= 1;
  598. >      large_enough: (2^Result) >= Maximum_character_code;
  599. >       end;
  600. >    Integer_bits: INTEGER is
  601. >      -- Number of bits in a value of type INTEGER.
  602. >       once
  603. >      c_inline_c("R=(CHAR_BIT*sizeof(int));");
  604. >       ensure
  605. >      meaningful: Result >= 1;
  606. >       end;
  607. >    Real_bits: INTEGER is
  608. >      -- Number of bits in a value of type DOUBLE.
  609. >       once
  610. >      c_inline_c("R=(CHAR_BIT*sizeof(float));");
  611. >       ensure
  612. >      meaningful: Result >= 1;
  613. >      meaningful: Result >= Real_bits;
  614. >       end;
  615. >    Double_bits: INTEGER is
  616. >      -- Number of bits in a value of type DOUBLE.
  617. >       once
  618. >      c_inline_c("R=(CHAR_BIT*sizeof(double));");
  619. >       ensure
  620. >      meaningful: Result >= 1;
  621. >      meaningful: Result >= Real_bits;
  622. >       end;
  623. >    Pointer_bits: INTEGER is
  624. >      -- Number of bits in a value of type REAL.
  625. >       once
  626. >      c_inline_c("R=(CHAR_BIT*sizeof(char *));");
  627. >       end;
  628. > end -- PLATFORM
  629. diff -r lib_std/platform.e /users/prof/colnet/SmallEiffel/lib_std/platform.elib_std/pointer.e /users/prof/colnet/SmallEiffel/lib_std/pointer.e
  630. 9,12c9,18
  631. < -- Note : corresponding C type is usually "void *".
  632. < --    In type STRING, POINTER is mapped "char *".
  633. < --    In type ARRAY and FIXED_ARRAY, POINTER is mapped as the 
  634. < --    C type of the generic actual argument.
  635. ---
  636. > -- Note : corresponding C type is mapped as "void *" except for
  637. > --        source files "string.e", "array.e" and "fixed_array.e".
  638. > --        In file "string.e", type POINTER is simply mapped as
  639. > --        the usual C type "char*".
  640. > --        In files "array.e" and "fixed_array.e", the mapping depends
  641. > --        on the actual generic type. When the actual generic type
  642. > --        is a reference type, POINTER is mapped as C type "T0 **".
  643. > --        When the actual type is an expanded type, POINTER is mapped 
  644. > --        as "<Ti>*" where <Ti> is the corresponding type of expanded
  645. > --        actual generic argument.
  646. 13a20
  647. 19a27,40
  648. >    is_not_void: BOOLEAN is
  649. >      -- Is the external POINTER a non Void pointer ?
  650. >      --  
  651. >      -- NOTE: as POINTER is an expanded class, the Eiffel
  652. >      --       test  Current /= Void is always true.
  653. >      --
  654. >       external "CSE"
  655. >       end;
  656. >    is_void: BOOLEAN is
  657. >       do
  658. >      Result := not is_not_void;
  659. >       end;
  660. diff -r lib_std/pointer.e /users/prof/colnet/SmallEiffel/lib_std/pointer.elib_std/pointer_ref.e /users/prof/colnet/SmallEiffel/lib_std/pointer_ref.e
  661. 10c10,15
  662. < end -- class INTEGER_REF
  663. ---
  664. >    set_item(value: like item) is
  665. >       do
  666. >      item := value;
  667. >       end;
  668. > end -- POINTER_REF
  669. diff -r lib_std/pointer_ref.e /users/prof/colnet/SmallEiffel/lib_std/pointer_ref.elib_std/real_ref.e /users/prof/colnet/SmallEiffel/lib_std/real_ref.e
  670. 17,18c17
  671. < creation {ANY}
  672. <    make
  673. ---
  674. > creation make
  675. 20c19
  676. < feature {ANY}
  677. ---
  678. > feature 
  679. 28a28,34
  680. > feature
  681. >    
  682. >    set_item(value: like item) is
  683. >       do
  684. >      item := value;
  685. >       end;
  686. diff -r lib_std/real_ref.e /users/prof/colnet/SmallEiffel/lib_std/real_ref.elib_std/std_error.e /users/prof/colnet/SmallEiffel/lib_std/std_error.e
  687. 39c39
  688. < feature {NONE}   
  689. ---
  690. > feature {RUN_FEATURE}   
  691. diff -r lib_std/std_error.e /users/prof/colnet/SmallEiffel/lib_std/std_error.elib_std/std_file.e /users/prof/colnet/SmallEiffel/lib_std/std_file.e
  692. 49,50c49
  693. <    -- NOTE: use only a few basic ANSI C functions.
  694. <    -- Try to use a as less as possible external C calls.
  695. ---
  696. >    -- NOTE: use only a few basic external C calls.
  697. 58a58,59
  698. >       local
  699. >      pf, pm: POINTER;
  700. 60,65c61,63
  701. <      f.extend('%U');
  702. <      m.extend('%U');
  703. <      c_inline_c("R=(T0 *)fopen(((Tstring *)a1)->_storage,%
  704. <              %((Tstring *)a2)->_storage);");
  705. <      f.remove_last(1);
  706. <      m.remove_last(1);
  707. ---
  708. >      pf := f.to_external;
  709. >      pm := m.to_external;
  710. >      c_inline_c("R=(void*)fopen(((char*)_pf),((char*)_pm));");
  711. 70d67
  712. <       alias "fclose"
  713. 71a69,72
  714. >    fputc(c: CHARACTER; stream_pointer: POINTER): CHARACTER is
  715. >       external "C"
  716. >       end;
  717. 72a74,83
  718. >    fgetc(stream_pointer : POINTER): CHARACTER is
  719. >      -- Result is of type CHARACTER because a int is a char !
  720. >       external "C"
  721. >       end;
  722. >    feof(stream_ptr: POINTER): BOOLEAN is
  723. >       do
  724. >      c_inline_c("R=feof((FILE*)C->_input_stream);");
  725. >       end;
  726. diff -r lib_std/std_file.e /users/prof/colnet/SmallEiffel/lib_std/std_file.elib_std/std_file_read.e /users/prof/colnet/SmallEiffel/lib_std/std_file_read.e
  727. 313,323d312
  728. <    
  729. <    fgetc(stream_pointer : POINTER): CHARACTER is
  730. <      -- Result is of type CHARACTER because a int is a char !
  731. <       external "CSE"
  732. <       alias "fgetc"
  733. <       end;
  734. <    
  735. <    feof(stream_ptr: POINTER): BOOLEAN is
  736. <       external "CSE"
  737. <       end;
  738. diff -r lib_std/std_file_read.e /users/prof/colnet/SmallEiffel/lib_std/std_file_read.elib_std/std_file_write.e /users/prof/colnet/SmallEiffel/lib_std/std_file_write.e
  739. 16,17c16
  740. < creation {ANY}
  741. <    connect_to
  742. ---
  743. > creation connect_to
  744. 19c18
  745. < feature {ANY}
  746. ---
  747. > feature 
  748. 38c37
  749. < feature {ANY}   
  750. ---
  751. > feature    
  752. 63c62
  753. <         put_character(s @ i);
  754. ---
  755. >         put_character(s.item(i));
  756. 192,193c191,193
  757. <    fputc(c: CHARACTER; stream_pointer: POINTER): CHARACTER is
  758. <       external "CSE"
  759. ---
  760. >    tmp_string: STRING is
  761. >       once
  762. >      !!Result.make(512);
  763. 195,196d194
  764. <    
  765. <    tmp_string: STRING is "0123456789001234567890";   
  766. diff -r lib_std/std_file_write.e /users/prof/colnet/SmallEiffel/lib_std/std_file_write.elib_std/std_input.e /users/prof/colnet/SmallEiffel/lib_std/std_input.e
  767. 40c40
  768. < feature {NONE} 
  769. ---
  770. > feature {RUN_FEATURE} 
  771. diff -r lib_std/std_input.e /users/prof/colnet/SmallEiffel/lib_std/std_input.elib_std/std_output.e /users/prof/colnet/SmallEiffel/lib_std/std_output.e
  772. 39c39
  773. < feature {NONE}   
  774. ---
  775. > feature {RUN_FEATURE}   
  776. diff -r lib_std/std_output.e /users/prof/colnet/SmallEiffel/lib_std/std_output.elib_std/string.e /users/prof/colnet/SmallEiffel/lib_std/string.e
  777. 13c13,14
  778. <      print_on
  779. ---
  780. >      print_on, fill_tagged_out_memory, eval_read_attribute, 
  781. >      eval_write_attribute
  782. 16,17c17
  783. < creation {ANY}
  784. <    make, copy, blank
  785. ---
  786. > creation make, copy, blank, from_external
  787. 24c24
  788. < feature {ANY}
  789. ---
  790. > feature 
  791. 32c32
  792. < feature {ANY} -- Creation / Modification :
  793. ---
  794. > feature -- Creation / Modification :
  795. 40d39
  796. <      count := 0;
  797. 44,45c43
  798. <           c_inline_c("C->_storage=(char *)%
  799. <                   %malloc((size_t)a1);");
  800. ---
  801. >           storage := malloc(needed_capacity);
  802. 47,48c45
  803. <           c_inline_c("C->_storage=(char *)%
  804. <                  %realloc(C->_storage,(size_t)a1);");
  805. ---
  806. >           storage := realloc(storage,needed_capacity);
  807. 52a50
  808. >      count := 0;
  809. 71c69
  810. < feature {ANY} -- No Modification of the receiver :
  811. ---
  812. > feature -- No Modification of the receiver :
  813. 79c77
  814. <    infix "@", item(index: INTEGER): CHARACTER is
  815. ---
  816. >    item, infix "@" (index: INTEGER): CHARACTER is
  817. 83a82
  818. >      if storage = Void then end;
  819. 112c111
  820. <    infix "<" (other: STRING): BOOLEAN is
  821. ---
  822. >    infix "<" (other: like Current): BOOLEAN is
  823. 170d168
  824. <            Result := false;
  825. 175c173
  826. <           (i = 0) or else (not item(i).same_as(other @ i))
  827. ---
  828. >           (i = 0) or else (not item(i).same_as(other.item(i)))
  829. 184c182
  830. <    is_equal(other: STRING): BOOLEAN is
  831. ---
  832. >    is_equal(other: like Current): BOOLEAN is
  833. 186,187d183
  834. <       require else
  835. <      true
  836. 288c284
  837. < feature {ANY} -- Modification :
  838. ---
  839. > feature -- Modification :
  840. 299c295
  841. <    copy(other: STRING) is
  842. ---
  843. >    copy(other: like Current) is
  844. 304,323c300,301
  845. <      i := other.count;
  846. <      count := i;
  847. <      if i > 0 then
  848. <         if capacity < i then
  849. <            if capacity = 0 then
  850. <           c_inline_c("C->_storage=(char *)%
  851. <                  %malloc((size_t)_i);");
  852. <            else
  853. <           c_inline_c("C->_storage=(char *)%
  854. <                  %realloc(C->_storage,(size_t)_i);");
  855. <            end;
  856. <            capacity := i;
  857. <         end;
  858. <         from
  859. <         until
  860. <            i = 0
  861. <         loop
  862. <            put(other.item(i),i);
  863. <            i := i - 1;
  864. <         end;
  865. ---
  866. >      if capacity < other.count then
  867. >         make(other.count);
  868. 324a303,311
  869. >      from
  870. >         i := other.count;
  871. >         count := i;
  872. >      until
  873. >         i = 0
  874. >      loop
  875. >         put(other.item(i),i);
  876. >         i := i - 1;
  877. >      end;
  878. 356c343
  879. <         extend(other @ i);
  880. ---
  881. >         extend(other.item(i));
  882. 391c378
  883. <         put(other @ i,i);
  884. ---
  885. >         put(other.item(i),i);
  886. 402a390
  887. >      if storage = Void then end;
  888. 509,519c497,503
  889. <      count := count + 1;
  890. <      if capacity < count then
  891. <         if capacity = 0 then
  892. <            capacity := 16;
  893. <            c_inline_c("C->_storage=(char *)%
  894. <                %malloc((size_t)C->_capacity);");
  895. <         else
  896. <            capacity := capacity + 16;
  897. <            c_inline_c("C->_storage=(char *)realloc(%
  898. <               %C->_storage,(size_t)C->_capacity);");
  899. <         end;
  900. ---
  901. >      if capacity > count then
  902. >      elseif capacity = 0 then
  903. >         capacity := 32;
  904. >         storage := malloc(capacity);
  905. >      else
  906. >         capacity := capacity + 32;
  907. >         storage := realloc(storage,capacity);
  908. 520a505
  909. >      count := count + 1;
  910. 642c627
  911. < feature {ANY}   -- Features which don't modify the string
  912. ---
  913. > feature -- Features which don't modify the string
  914. 658c643
  915. < feature {ANY} -- Conversion :
  916. ---
  917. > feature -- Conversion :
  918. 834c819
  919. < feature {ANY} -- Printing :
  920. ---
  921. > feature -- Printing :
  922. 837,838d821
  923. <       local
  924. <      i: INTEGER;
  925. 840,849c823,825
  926. <      file.put_character('%"');
  927. <      from  
  928. <         i := 1;
  929. <      until
  930. <         i > count
  931. <      loop
  932. <         file.put_character(item(i));
  933. <         i := i +1;
  934. <      end;
  935. <      file.put_character('%"');
  936. ---
  937. >            tagged_out_memory.clear;
  938. >      fill_tagged_out_memory;
  939. >      file.put_string(tagged_out_memory);
  940. 852c828,833
  941. < feature {ANY} -- Other features :
  942. ---
  943. >    fill_tagged_out_memory is
  944. >       do
  945. >      tagged_out_memory.extend('%"'); 
  946. >      tagged_out_memory.append(Current); 
  947. >      tagged_out_memory.extend('%"'); 
  948. >       end;
  949. 853a835,836
  950. > feature -- Other features :
  951. >    
  952. 954a938,939
  953. > feature -- Interfacing with C string :
  954. 957,960c942,947
  955. <      -- Gives address of a copy of the contents of the string
  956. <      -- adding null character at end (for C use). 
  957. <      -- NOTE: do a malloc(`count' + 1), thus it is not an access 
  958. <      -- to `storage'.
  959. ---
  960. >      -- Gives C access to the internal storage of STRING.
  961. >      -- To be compatible with C, a null character is always
  962. >      -- appended at the end of internal storage. 
  963. >      -- The added null character is not part of the Eiffel STRING.
  964. >      -- 
  965. >      -- NOTE: do not free/realloc the Result.
  966. 962,964c949,953
  967. <      c_inline_c("R=(char *)malloc((C->_count)+1);%N%
  968. <             %memcpy(R,C->_storage,C->_count);%N%
  969. <             %((char *)R)[C->_count]='\0';");
  970. ---
  971. >      extend('%U');
  972. >      remove_last(1);
  973. >      Result := storage;
  974. >       ensure
  975. >      Result.is_not_void
  976. 966c955,978
  977. <    
  978. ---
  979. >    from_external(p: POINTER) is
  980. >      -- Assume `p' is the addresse of a C string.
  981. >      -- Initialize the string using `p'.
  982. >      -- The null character is not part of the Eiffel STRING.
  983. >       do
  984. >      if storage.is_not_void then
  985. >         free(storage);
  986. >      end;
  987. >      from
  988. >         storage := p;
  989. >         capacity := 1;
  990. >         count := 1;
  991. >      until
  992. >         item(capacity) = '%U'
  993. >      loop
  994. >         capacity := capacity + 1;
  995. >         count := capacity;
  996. >      end;
  997. >      count := count - 1;
  998. >       ensure
  999. >      p = to_external;
  1000. >       end;
  1001. 969c981,1006
  1002. <    tmp_string: STRING is "ABCDEFGHIJKLMN...";
  1003. ---
  1004. >    tmp_string: STRING is 
  1005. >       once
  1006. >      !!Result.make(256);
  1007. >       end;
  1008. > feature {PROC_CALL_1}
  1009. >    malloc(size: INTEGER): POINTER is
  1010. >       require
  1011. >      size > 0
  1012. >       do
  1013. >      c_inline_c("R=(char*)malloc((size_t)a1);");
  1014. >       end;
  1015. >    realloc(pointer: POINTER; size: INTEGER): POINTER is
  1016. >       require
  1017. >      size > 0
  1018. >       do
  1019. >      c_inline_c("R=(char*)realloc(a1,(size_t)a2);");
  1020. >       end;
  1021. >    free(p: POINTER) is
  1022. >       external "C"
  1023. >       end;
  1024. > feature
  1025. 970a1008,1035
  1026. >    eval_read_attribute(name: STRING; dest: POINTER) is
  1027. >       do 
  1028. >      if ("count").is_equal(name) then
  1029. >         eval_virtual_machine.put_integer(dest,count);
  1030. >      elseif ("capacity").is_equal(name) then
  1031. >         eval_virtual_machine.put_integer(dest,capacity);
  1032. >      else
  1033. >         check
  1034. >            ("storage").is_equal(name)
  1035. >         end;
  1036. >         eval_virtual_machine.put_pointer(dest,storage);
  1037. >      end;
  1038. >       end;
  1039. >    eval_write_attribute(name: STRING; source: POINTER) is
  1040. >       do 
  1041. >      if ("count").is_equal(name) then
  1042. >         count := eval_virtual_machine.get_integer(source);
  1043. >      elseif ("capacity").is_equal(name) then
  1044. >         capacity := eval_virtual_machine.get_integer(source);
  1045. >      else
  1046. >         check
  1047. >            ("storage").is_equal(name)
  1048. >         end;
  1049. >         storage := eval_virtual_machine.get_pointer(source);
  1050. >      end;
  1051. >       end;
  1052. 980d1044
  1053.